<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 发送一条信息的简单函数
        function sendMessage(msg, obj) {
            // 如果消息和对象（的参数）都被提供
            if (arguments.length == 2) {
                // 给对象发送消息
                obj.handleMeg(msg);
            } else {
                // 否则，仅显示默认的错误信息
                console.log(msg);
            }
        }
        sendMessage('hello world');
    </script>
</body>

</html>